﻿using LdtJudge.DatabaseCore.Interfac;
using LdtJudge.DataEngine.CallInterface.CommHelp;
using LdtJudge.DataEngine.CallInterface.ConfiCenter;
using LdtJudge.DataEngine.Model.DataModel.SystemtableModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace LdtJudge.DataEngine.Data
{
    /// <summary>
    /// 数据访问类:DALSYS_Express_GroupSituation
    /// </summary>
    public class DALSYS_Express_GroupSituation
    {
        
        
        private static  IFreeSql freeSql = FreeSQLHelp.GetFreeSQL("Ldt_JudgeDocSystem");

        public DALSYS_Express_GroupSituation()
        {
            //sqlSysexpress = new Data.SqlHandle(connsys).GetSqlHelper;
        }
       
        #region  Method
        /// <summary>
        /// 提取组合情形所对应的表述ID
        /// </summary>
        /// <returns>表述ID</returns>
        public string GetExpressWordID(string groupID)
        {
            var listExpress = freeSql.Select<SYS_Express_Word>().Where(a => a.MS_ID == groupID && (a.EW_UserID == "" || a.EW_UserID == null)).OrderBy(a => a.EW_UseCount).ToList();
            if (listExpress.Count>0)
            {
              return listExpress[0].EW_ID;
            }
            return "";
        }

        public SYS_Express_Word GetExpressWordIDModel(string groupID)
        {
            var listExpress = freeSql.Select<SYS_Express_Word>().Where(a => a.MS_ID == groupID && (a.EW_UserID == "" || a.EW_UserID == null)).OrderBy(a => a.EW_UseCount).ToList();
            if (listExpress.Count > 0)
            {
                return listExpress[0];
            }
            return null;
        }
        /// <summary>
        /// 行政执法
        /// </summary>
        /// <param name="groupID"></param>
        /// <returns></returns>
        public string GetExpressWordIDxzzf(string groupID) 
        {
            var listExpress = freeSql.Select<SYS_Express_Word>().Where(a => a.MS_ID == groupID && (a.EW_UserID == "" || a.EW_UserID == null) && a.EW_WordPurpose==3).OrderBy(a => a.EW_UseCount).ToList();
            string listExpress1 = freeSql.Select<SYS_Express_Word>().Where(a => a.MS_ID == groupID && (a.EW_UserID == "" || a.EW_UserID == null)).OrderBy(a => a.EW_UseCount).ToSql();
            if (listExpress.Count > 0)
            {
                return listExpress[0].EW_ID;
            }
            return "";
        }

        ///// <summary>
        ///// 对象实体绑定数据
        ///// </summary>
        //public Model.DataModel.SysCommon.MSYS_Express_GroupSituation ReaderBind(IDataReader dataReader)
        //{
        //    Model.DataModel.SysCommon.MSYS_Express_GroupSituation model = new Model.DataModel.SysCommon.MSYS_Express_GroupSituation();
        //    object ojb;
        //    model.ES_IDs = dataReader["ES_IDs"].ToString();
        //    model.ES_Name = dataReader["ES_Name"].ToString();
        //    model.ES_ParentID = dataReader["ES_ParentID"].ToString();
        //    ojb = dataReader["ES_IsCombine"];
        //    if (ojb != null && ojb != DBNull.Value)
        //    {
        //        model.ES_IsCombine = (int)ojb;
        //    }
        //    ojb = dataReader["ES_SituationType"];
        //    if (ojb != null && ojb != DBNull.Value)
        //    {
        //        model.ES_SituationType = (int)ojb;
        //    }
        //    ojb = dataReader["ES_IsMakeUp"];
        //    if (ojb != null && ojb != DBNull.Value)
        //    {
        //        model.ES_IsMakeUp = (int)ojb;
        //    }
        //    model.ES_SituationIds = dataReader["ES_SituationIds"].ToString();
        //    return model;
        //}

        #endregion  Method
    }
}
